package com.iris.live.services.data.repositories;

import com.iris.live.services.data.models.SnpSettingModel;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import java.math.BigDecimal;

public interface SNPSettingRepository extends JpaRepository<SnpSettingModel, Integer>, JpaSpecificationExecutor<SnpSettingModel> {
    @Modifying
    @Query("update SnpSettingModel u "
    		+ "set u.biStandardConfigMsrpTaxIncluded = ?1,"
    		+ "u.cashDiscountAndSiCostCelling = ?2,u.siCost = ?3,"
    		+ "u.standardConfigurationAreaPriceLimitSnpTaxIncluded = ?4,u.bmbsRetailSi = ?5,"
    		+ "u.bmbsWholesaleSi = ?6 "
    		+ "where u.id = ?7")
    int updateSnpSettingData(BigDecimal bscmti, BigDecimal cdascc,BigDecimal siCost,BigDecimal scaplsti,
    		BigDecimal brs,BigDecimal bwss,int id);
    
    @Modifying
    @Query("update SnpSettingModel u set u.bmbsTa = ?1, u.lshTa = ?2,u.apperanceCode=?4 where u.id = ?3")
    int updateSnpSettingTA(BigDecimal bmbsTA, BigDecimal lshTA, int id,int carTypeCode);
    
    @Modifying
    @Query("delete SnpSettingModel u where u.yM = ?1 and u.permit = ?2")
    int deleteSnpDataByYmAndPermit(String ym,String permit);

    @Modifying
    @Query("delete SnpSettingModel u where u.permit = ?1")
    int deleteSnpDataByPermit(String permit);

    @Modifying
    @Query("delete SnpSettingModel u where u.permit = ?1 and (u.yM = ?2 or u.yM = ?3)")
    int deleteSnpDataByPermit(String permit, String ym1, String ym2);
}
